<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
    <style>
        .active{
            background-color: black;
            color: aliceblue;
        }
    </style>
</head>
<body>
    <div id="app">
        <ul>
            <li :class="{active: num === index}" @click="active(index)"    v-for="(item,index) in goods" >商品名称：-------{{item.name}},商品数量： -------{{item.num}},商品价格： -------{{item.price}}</li>
        </ul>
    </div>

    <script>
        new Vue({
            el: '#app',
            data:{
                num:-1,
                goods:[ 
                        {id:100, name:"芙蓉王", num:5, price:25},
                        {id:100, name:"zeppo打火机", num:8, price:2.5},
                        {id:100, name:"杨玉虎年限定", num:999, price:168},
                        {id:100, name:"6个核弹", num:6, price:999},
                        {id:100, name:"核显卡", num:100, price:1195},
                        {id:100, name:"旺仔牛奶", num:23, price:5},
                    ]
            },methods:{
                active(index){
                    this.num = index;
                    console.log(this.num,index);
                }
            }

        })
    </script>
</body>
</html>